﻿<cfsilent>
	<cfscript>
	
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		markAdvice = getProperty("serviceFactory").getBean("markAdvice");
		
		sql = "SELECT cls_id, cls_name, sbj_id, grade FROM t_class WHERE cls_id = :classId "; 
		
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="classId", value=event.getArg('Class'), cfsqltype="cf_sql_char" ); 
		
		rs_classEntity = queryObj.execute( sql=sql ).getResult(); 
		
		sql = "SELECT academic_year, academic_term, year_term, term_id FROM t_term WHERE year_term = :yearTerm "; 
		
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="yearTerm", value=rs_classEntity.grade, cfsqltype="cf_sql_char" ); 
		
		rs_term = queryObj.execute( sql=sql ).getResult(); 

		sql = "SELECT 
					 a.stu_id, 
					 a.stu_name, 
					 a.stu_sex, 
					 a.stu_name_english, 
					 a.stu_idcard, 
					 c.student_prop, 
					 a.nationality, 
           			(select to_char(d.name) from i_code_info d where d.code_id = c.st_id ) name 
				FROM 
					 t_student a 
					 INNER JOIN t_student_status c ON c.stu_id = a.stu_id  
				WHERE 
					EXISTS(
						SELECT 1 from i_stu_class_info e WHERE e.stu_id = a.stu_id and e.cls_id =:classId
					)
				ORDER BY 
					a.stu_id DESC"; 
		
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="classId", value=rs_classEntity.cls_id, cfsqltype="cf_sql_varchar" ); 
		
		rs_student = queryObj.execute( sql=sql ).getResult(); 
		
		/* 读取班级学生分数统计 */
		sql = "SELECT 
				a.stu_id, a.stu_name, a.stu_sex, 
				b.credit, b.credit_req, b.credit_opt, b.credit_phy, b.credit_com, b.credit_failure, 
				b.credit_req_avgpt, b.credit_avgpt, 
				c.student_prop 
				FROM t_student a 
				INNER JOIN t_student_profile b ON a.stu_id = b.stu_id 
				INNER JOIN t_student_status c ON c.stu_id = a.stu_id 
				WHERE 
					EXISTS(
						SELECT 1 FROM i_stu_class_info d where d.stu_id = a.stu_id and d.cls_id = :classId 
					) ";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="classId", value=rs_classEntity.cls_id, cfsqltype = "cf_sql_varchar");
		
		rs_studentMark = queryObj.execute( sql=sql ).getResult();
		
		/* 读取班级学生不及格分数 */
		sql = "SELECT a.*, b.course_name, b.course_code, d.tch_name, e.stu_name,e.stu_sex ,f.student_prop 
				FROM t_student_mark a 
				INNER JOIN t_course b ON b.cid = a.cid 
				INNER JOIN t_task c ON c.tsk_id = a.task_Id 
				INNER JOIN t_teacher d ON d.tch_id = c.tch_id 
				INNER JOIN t_student e ON e.stu_id = a.stu_id 
				 INNER JOIN t_student_status f ON f.stu_id = a.stu_id  
				WHERE 
					EXISTS(
						SELECT 1 FROM i_stu_class_info d where d.stu_id = a.stu_id and d.cls_id = :classId 
					) 
					AND a.term_id = :termId 
					AND a.mark_mode != '5' 
					AND a.mark_result < 60 ";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="classId", value=rs_classEntity.cls_id, cfsqltype = "cf_sql_varchar");
		queryObj.addParam( name="termId", value=rs_term.term_id, cfsqltype = "cf_sql_char");
		
		rs_studentMarkRsit = queryObj.execute( sql=sql ).getResult();
		

		
		event.setArg("pageTitle", "教学运行基础数据 - 学生学籍 - 班级学生列表 - " & rs_classEntity.cls_name);
		
		currentTab = event.getArg("TabID", "labStudent");
		
		targetArgs = structNew();
		structInsert(targetArgs, "SubID", rs_classEntity.sbj_id, true);
		structInsert(targetArgs, "TabID", "labGrade" & rs_classEntity.grade, true);
		
		passArgs = structNew();
		
		structInsert(passArgs,"Class", event.getArg('Class') );
		
		/* 计算在校学生人数 */
		inSchool = 0;
		
		for ( i=1; i LTE rs_student.recordCount; i++ ){
			propertyAdvice.parseProperty(rs_student["student_prop"][i]);
			if ( propertyAdvice.getInSchool() ) inSchool++;
		}
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('studentByHeadTeacher', targetArgs)#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">学生学籍管理</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i><cfoutput>#rs_classEntity.cls_name#</cfoutput>班学生列表
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labStudent">class="active"</cfif> id="labStudent" tabTarget="Student">学籍档案</span>
						<span <cfif currentTab eq "labDetail">class="active"</cfif> id="labDetail" tabTarget="Detail">详细信息</span>
                             <span <cfif currentTab eq "labClass">class="active"</cfif> id="labClass" tabTarget="Class">学生学习进度</span>
                             <span <cfif currentTab eq "labResitStudent">class="active"</cfif> id="labResitStudent" tabTarget="ResitStudent">补考学生名单</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Student" class="tabContent">

					<div class="noticeBlock">
                         	<div class="operation">
                                   <a class="uiButton" href="<cfoutput>#buildURL('studentSearch', passArgs)#</cfoutput>"><i class="mrs img btnAdd"></i></i><span class="uiButtonText"><b>添加学生</b></span></a>
                              </div>
						<p><span class="img icon16x16 message"></span>该行政班在籍学生 <em><cfoutput>#rs_student.recordCount#</cfoutput></em> 名, 目前在校学生 <em><cfoutput>#inSchool#</cfoutput></em> 名. </p>
                              
						<hr/>
					</div>
					
					<div class="clearfix">
						
                        <cfloop query="rs_student">
							
							<cfset structInsert(passArgs, "STU", rs_student.stu_id, true) />
							<cfset propertyAdvice.parseProperty(rs_student.student_prop) />
							
							<div class="UISmallUserCard" style="height:70PX">
								<div class="cardContent <cfif not propertyAdvice.getInSchool()>disabled</cfif>">
									<a href="<cfoutput>#buildURL('studentProfileView', passArgs)#</cfoutput>"><img class="img" src="<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/graphic/userSmall.png" style="background-image: url('<cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/student/portrait/<cfoutput>#left(rs_student.stu_id,4)#</cfoutput>/<cfoutput>#rs_student.stu_id#</cfoutput>.jpg');"></a>
									<div class="cardDetail">
										<h3><a href="<cfoutput>#buildURL('studentProfileView', passArgs)#</cfoutput>"><cfoutput>#rs_student.stu_name#</cfoutput></a> (<cfoutput>#rs_student.nationality#</cfoutput>)</h3>
										<p><cfoutput>#rs_student.stu_id#</cfoutput></p>
									</div>
								</div>
							</div>
							
						</cfloop>

					</div>
					
				</div>
				
				<div id="Detail" class="tabContent">
				
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td>学号</td>
									<td>姓名</td>
									<td width="25">性别</td>
									<!---<td width="100">护照号</td>--->
                                             <td>护照名</td>
									<td >学生类型</td>
									<td>国籍</td>
									<td>在校</td>
									<td colspan="2" align="center" width="35">操作</td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_student">
									
									<cfset row++ />
									<cfset structInsert(passArgs, "STU", rs_student.stu_id, true) />
									<cfset propertyAdvice.parseProperty(rs_student.student_prop) />
									
									<tr class="editRows <cfif not propertyAdvice.getInSchool()>alertRow</cfif>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_student.stu_id#</cfoutput></span></td>
										<td><cfoutput>#rs_student.stu_name#</cfoutput></td>
										<td><cfif rs_student.stu_sex eq "1">男<cfelse>女</cfif></td>
										<!---<td><span class="numeric"><cfoutput>#rs_student.stu_idcard#</cfoutput></span></td>--->
                                                  <td><cfoutput>#rs_student.stu_name_english#</cfoutput></td>
										<td><cfif rs_student.name eq "" >无<cfelse><cfoutput>#rs_student.name#</cfoutput></cfif></td>
										<td><cfoutput>#rs_student.nationality#</cfoutput></td>
										<td><cfif propertyAdvice.getInSchool()>是<cfelse><span class="alertCell">否</span></cfif></td>
										<td><a href="<cfoutput>#buildURL('studentProfileView', passArgs)#</cfoutput>" title="查看" class="stat details"></a></td>
                                                  <td><a href="<cfoutput>#buildURL('classRemoveStudentDo', passArgs)#</cfoutput>" onclick="return checked();" title="删除" class="stat delete"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
					
				</div>
                    
                    <script language="javascript" type="text/javascript">
				
                    	function checked(){
						var msg = "您真的确定要删除吗？\n\n请确认！"; 
						if (confirm(msg)==true){ 
							return true; 
						}else{ 
							return false; 
						} 
					}
                    
                    </script>
				
                    
                   <div id="Class" class="tabContent">
					
					<div class="noticeBlock">
						<!---<div class="operation">
							<a class="uiButton" target="_blank" href="<cfoutput>#buildURL('classMarkPassPrint', passArgs)#</cfoutput>"><i class="mrs img btnPrint"></i><span class="uiButtonText">打印班级通过课程成绩单</span></a>
							<a class="uiButton" target="_blank" href="<cfoutput>#buildURL('classMarkPrint', passArgs)#</cfoutput>"><i class="mrs img btnPrint"></i><span class="uiButtonText">打印班级成绩单</span></a>
							<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('studentMarkByClassDownloadExcel', passArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载班级学分统计</span></a>
						</div>--->
						<h3><cfoutput>#rs_classEntity.cls_name#</cfoutput></h3>
						<p><span class="img icon16x16 message"></span>该行政班在籍学生 <em><cfoutput>#rs_student.recordCount#</cfoutput></em> 名, 目前在校学生 <em><cfoutput>#inSchool#</cfoutput></em> 名. </p>
						<hr/>
					</div>
					
					<cfset row = 0 />
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="18"></td>
								<td >学号</td>
								<td>姓名</td>
								<td >性别</td>
								<td >总学分</td>
								<td>必修</td>
								<td>选修</td>
								<td width="18"></td>
							</tr>
						</thead>
						<tbody>
							<cfloop query="rs_studentMark">
									
								<cfset row++ />
								<cfset structInsert(passArgs, "STU", rs_studentMark.stu_id, true) />
								<cfset structDelete(passArgs, "TabID", false) />
								<cfset propertyAdvice.parseProperty( rs_studentMark.student_prop ) />
								
								<tr class="editRows <cfif not propertyAdvice.getInSchool()>cancelRow</cfif>">
									<td class="index"><cfoutput>#row#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#rs_studentMark.stu_id#</cfoutput></span></td>
									<td><cfoutput>#rs_studentMark.stu_name#</cfoutput></td>
									<td><cfif rs_studentMark.stu_sex eq "1">男<cfelse>女</cfif></td>
									<td><cfif rs_studentMark.credit gt 0><span class="numeric"><cfoutput>#numberFormat( rs_studentMark.credit, "_.__" )#</cfoutput></span></cfif></td>
									<td><cfif rs_studentMark.credit_req gt 0><span class="numeric"><cfoutput>#numberFormat( rs_studentMark.credit_req, "_.__" )#</cfoutput></span></cfif></td>
									<td><cfif rs_studentMark.credit_opt gt 0><span class="numeric"><cfoutput>#numberFormat( rs_studentMark.credit_opt, "_.__" )#</cfoutput></span></cfif></td>
									
									<td><a href="<cfoutput>#buildURL('studentMarkView', passArgs)#</cfoutput>" class="stat details"></a></td>
								</tr>
								
							</cfloop>
						</tbody>
					</table>
					
				</div>
                    
                     <div id="ResitStudent" class="tabContent">
					
					<div class="noticeBlock">
						<h3><cfoutput>#rs_classEntity.cls_name#</cfoutput></h3>
						<p><span class="img icon16x16 message"></span>以下是该班学生在 <em><cfoutput>#rs_term.academic_year#</cfoutput> -<cfoutput>#rs_term.academic_term#</cfoutput> </em>学期期末不及格学生名单. </p>
						<hr/>
					</div>
					
					<cfset row = 0 />
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="18"></td>
								<td >学号</td>
								<td>姓名</td>
								<td >性别</td>
								<td >课程</td>
								<td>任课教师</td>
								<td>期末成绩</td>
                                        <td>补考成绩</td>
							</tr>
						</thead>
						<tbody>
							<cfloop query="rs_studentMarkRsit">
									
								<cfset row++ />
								<cfset propertyAdvice.parseProperty( rs_studentMarkRsit.student_prop ) />
								
								<tr class="editRows <cfif not propertyAdvice.getInSchool()>cancelRow</cfif>">
									<td class="index"><cfoutput>#row#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#rs_studentMarkRsit.stu_id#</cfoutput></span></td>
									<td><cfoutput>#rs_studentMarkRsit.stu_name#</cfoutput></td>
									<td><cfif rs_studentMarkRsit.stu_sex eq "1">男<cfelse>女</cfif></td>
                                             <td><cfoutput>#rs_studentMarkRsit.course_name#</cfoutput></td>
                                             <td><cfoutput>#rs_studentMarkRsit.tch_name#</cfoutput></td>
									<td><cfif rs_studentMarkRsit.mark_mode eq 0><span class="numeric"></cfif><cfoutput>#markAdvice.getMark(rs_studentMarkRsit.mark_mode,rs_studentMarkRsit.mark_result, rs_studentMarkRsit.mark_note)#</cfoutput></span></td>
									<td><cfif rs_studentMarkRsit.mark_mode eq 0><span class="numeric"></cfif><cfoutput>#markAdvice.getMarkResit(rs_studentMarkRsit.mark_mode, rs_studentMarkRsit.mark_resit, rs_studentMarkRsit.mark_renote, 100)#</cfoutput></span></td>
									
									
								</tr>
								
							</cfloop>
						</tbody>
					</table>
					
				</div>
                    
                    
			</div>
		</li>
	</ul>
</div>